Repository navigation
Bound the dependency and Auto Find file searches in a home folder workspace - #2002
Open
Jean-François Gagné (JeanFrancoisGagne) wants to merge 9 commits into
Open
Jean-François Gagné (JeanFrancoisGagne) wants to merge 9 commits into
Jean-François Gagné (JeanFrancoisGagne) wants to merge 9 commits into
Conversation
findFilesInWorkspace wraps workspace.findFiles with a result cap and a 30 second time limit, linked to the caller's cancellation token. A workspace folder that is the user's home folder, or one of its parents, is not searched and the skip is logged; the other folders are searched through a RelativePattern each. With no home folder open, the call is the same single search as before. findFiles runs ripgrep with --no-ignore and follows symlinks, so a search rooted at the home folder walks the whole profile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
getProjectInstallable ran four findFiles calls with no maxResults. In a workspace opened on the home folder each one walked the whole profile for minutes before the package picker or Quick Create could continue. Each search now goes through findFilesInWorkspace with a cap of 10,000 files and the 30 second time limit, and skips a home folder workspace. The progress and caller tokens still cancel every search. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AutoFindProjects.create ran findFiles with no maxResults and no token, so in a workspace opened on the home folder it walked the whole profile before showing the picker. The search now goes through findFilesInWorkspace with a cap of 1,000 marker files and the 30 second time limit, and skips a home folder workspace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
VS Code resolves a cancelled findFiles to an empty list, not to the matches found so far (searchService.ts raceCancellationError, mainThreadWorkspace.ts returns null, extHostWorkspace.ts maps null to []). The 30 second limit therefore turned a slow dependency search into "no dependencies", so Quick Create made a venv without them, and a slow Auto Find search into "No projects found". findFilesInWorkspace now passes the caller's token to findFiles unchanged. The dependency search keeps its cancellable progress notification or the caller's token, as before this branch. The tests that checked a linked token go back to checking the caller's token. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
getProjectInstallable keeps only files under the projects it is given, but the home folder check skipped the whole workspace folder. With the workspace on the home folder and a project at ~/code/app, Quick Create made the venv without the project's dependencies and the package picker left out its requirements files. findFilesInWorkspace takes neededFolders. In place of a workspace folder that is the home folder or contains it, it searches each needed folder inside it, one RelativePattern each, and still skips a needed folder that is home or contains it. It skips a needed path that is a file or missing, because ripgrep cannot start there and a failed start fails the whole findFiles call. Nested and repeated folders are searched once. The dependency search passes the project folders; Auto Find passes none and keeps skipping the home folder. The vscode mock's RelativePattern now takes a Uri base, as VS Code's does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The call-site tests checked only that maxResults was a positive integer, so raising MAX_DEPENDENCY_FILES or MAX_PROJECT_MARKERS to Number.MAX_SAFE_INTEGER still passed. The dependency search test now checks each of the four patterns with a cap of 10,000, and the Auto Find test checks a cap of 1,000. With both caps raised to Number.MAX_SAFE_INTEGER in the compiled code, the two tests fail (72 passing, 2 failing); with the real caps they pass (74 passing). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In a workspace opened on the home folder, Auto Find searched nothing and then showed "No projects found". The reason went only to traceLog, so the user read that no projects exist when none were looked for. findFilesInWorkspace's module now exports getHomeWorkspaceFolders, which returns the workspace folders it never searches whole. When Auto Find finds nothing and one of those folders exists, the error names the folder, says it is the home folder or contains it, and says to open the project folder instead. The plain message now comes from ProjectCreatorString.noProjectsFound, which held the same text but was unused. Before the change, the Auto Find test that checks the message and the two getHomeWorkspaceFolders tests failed; after it they pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The Set Up Environments for Inline Script Files command ran
findFiles('**/*.{py,Py,pY,PY}') over the whole workspace. In a
workspace opened on the home folder that walk covers the whole
profile, and its first 1,000 matches can all come from Python installs
under AppData, whose headers the command then reads.
The search now goes through findFilesInWorkspace with the same pattern,
exclude and cap of 1,000 (MAX_INLINE_SCRIPT_FILES), so it skips a
workspace folder that is the home folder or contains it and still
searches every other folder. When nothing is found and a folder was
skipped, the message names the folder and says to open the folder that
holds the scripts.
The new test failed before the change (findFiles ran on the home
folder) and passes after it. The test that checks the pattern now reads
the first three arguments, since the helper also passes the token slot.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Runs Prettier with the repository's .prettierrc.js on the ten files the branch changes, so npx prettier --check passes on each. The branch itself added one deviation, the vscode import line in pipUtils.unit.test.ts, which now wraps. The other changes were already there before this branch: they are what format on save in the workspace settings would produce. This commit changes formatting only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Jean-François Gagné (JeanFrancoisGagne)
marked this pull request as ready for review
November 9, 2026 19:23
|
Jean-François Gagné (@JeanFrancoisGagne) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In a VS Code window opened on the user's home folder (for example
C:\Users\<name>), three actions start file searches that walk the whole profile, AppData and tool caches included, and take minutes:Until ripgrep finishes, the Searching for dependencies notification stays up or Auto Find shows nothing, and ripgrep keeps the CPU and disk busy the whole time.
Cause
workspace.findFilesruns ripgrep with--no-ignoreand, by default,--follow. The excludes these callers pass leave most of a profile in scope, and none of the calls passesmaxResults:src/managers/builtin/pipUtils.ts:459-462(before this PR) runs four searches in parallel ingetProjectInstallable.src/features/creators/autoFindProjects.ts:94(before this PR) runs one search inAutoFindProjects.create.Fix
src/common/workspaceSearch.ts:42addsfindFilesInWorkspace({ label, include, exclude, maxResults, neededFolders, token }):os.homedir()or one of its parents, it makes the same singlefindFilescall as before, plusmaxResults. The caller's token goes tofindFilesunchanged.neededFoldersinside it, oneRelativePatterneach, and skips a needed folder that is itself home or a parent of home. The check usesisSameOrParentPath, so separators, a trailing separator and case on Windows do not matter.traceLognames the folder, the reason and the folders searched instead.findFilescall. Projects can be single.pyfiles. A folder inside another needed folder is searched once.findFilesresolves to an empty list, not to the matches found so far:searchService.tsraces the provider against the token,mainThreadWorkspace.tsreturnsnullon cancel, andextHostWorkspace.tsmapsnullto[]. A limit would turn a slow search into "nothing found".traceWarnrecords a search that reached its cap.pipUtils.ts:431,464-484: each of the four dependency searches goes through the helper withmaxResults10,000 per pattern and the project folders asneededFolders.getProjectInstallablealready keeps only files under those projects, so in a home folder workspace it finds the same files as before without walking the rest of the profile. Quick Create installs from every match under the project, so this cap sits far above what a large monorepo holds. The progress notification and the caller's token still cancel every search.autoFindProjects.ts:20,101: the marker search goes through the helper withmaxResults1,000 and noneededFolders. Each folder with a marker becomes one item in a multi-select picker, and a picker with 1,000 items is already too long to use.In a home folder workspace:
Not changed:
src/features/views/workspacePythonContext.ts:31already passesmaxResults1, and Avoid a full workspace search per Python file event #1999 adds its token.src/features/inlineScript/setupEnvironment.ts:288already passesmaxResults1,000 (MAX_INLINE_SCRIPT_FILES) but no token. A follow-up could move it to the helper.Testing
Windows 11, Node 24.21.0.
npm ci, thennpx tsc -p . --outDir out(thecompile-testscommand): exit 0.npx eslint --config=eslint.config.mjson the seven touched files: exit 0.build/.mocha.unittests.json:npx mocha --no-config --ui tdd --require source-map-support/register --require out/test/unittests.js --timeout 180000 out/test/common/workspaceSearch.unit.test.js out/test/managers/builtin/pipUtils.unit.test.js out/test/features/creators/autoFindProjects.unit.test.jsResult: 88 passing.
out/test/managers/common/packageWatcher.unit.test.js, which also buildsRelativePatternthrough the vscode mock: 39 passing.findFilesfake that returns[]once its token cancels, as VS Code does, the tests for a search that runs for minutes failed for the helper,getProjectInstallableand Auto Find, and so did the tests that check the caller's token reachesfindFiles(73 passing, 9 failing).~/code/appin a home folder workspace got no dependency files, and the helper searched no needed folder (85 passing, 3 failing).findFilescall'smaxResultsand tokengetProjectInstallablesuites now stubgetWorkspaceFolders, which the helper reads.RelativePatternaccepts aUribase, as VS Code's does.Context
#1989 reports a VS Code window opened on the home folder that froze a Windows laptop. #1999 fixes the
workspaceHasPythonwatcher behind that report. Reviewing #1999 turned up these unboundedfindFilescalls, which #1999 does not touch. They run on user actions rather than on file events, so each action starts one walk instead of one per changed file, but each walk still covers the whole profile.Follow-up in this PR
Fix:
src/common/workspaceSearch.tsexportsgetHomeWorkspaceFolders(): the workspace folders the helper never searches whole. When Auto Find finds nothing in a home folder workspace, its error now names the skipped folder, says it is the home folder or contains it, and says to open the project folder instead (ProjectCreatorString.noProjectsFoundInHomeFolder). The plain case uses the existingProjectCreatorString.noProjectsFoundinstead of a hard-coded string.src/features/inlineScript/setupEnvironment.ts: the Set Up Environments for Inline Script Files search goes throughfindFilesInWorkspacewith the same pattern, exclude and cap of 1,000 (MAX_INLINE_SCRIPT_FILES). It skips a home folder workspace folder and says so in its message.Format the files this branch touches with Prettier) only runs Prettier with.prettierrc.json the ten touched files. Most of its changes were already off-format at the base; drop it if a smaller diff is preferred.Testing:
Number.MAX_SAFE_INTEGER, the two tests fail (72 passing, 2 failing).getHomeWorkspaceFoldersfailed before their change (125 passing, 4 failing) and pass after.setupEnvironment.registration.unit.test.js: 130 passing. eslint andnpx prettier --checkon the ten touched files: exit 0.🤖 Generated with Claude Code